package com.dgyt.contract.config;//package com.dgyt.contract.config;
//
//import com.dgyt.contract.constant.Constant;
//import com.dgyt.contract.reptile.PhantomJSRequestSet;
//import org.openqa.selenium.By;
//import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.chrome.ChromeOptions;
//import org.openqa.selenium.phantomjs.PhantomJSDriver;
//import org.openqa.selenium.remote.RemoteWebDriver;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.PostConstruct;
//
//import java.util.HashMap;
//
//import static java.util.concurrent.TimeUnit.SECONDS;
//
///**
// * Created with IntelliJ IDEA.
// * User: SQ
// * Date: 2020/1/15
// * Time: 10:42
// * Description:
// */
//@Configuration
//public class Init implements ApplicationRunner {
//    @Value("${ChromeFile}")
//    private String chromefile;
//    @Value("${ChromeDriveDir}")
//    private String chromedrivedir;
//
////    @PostConstruct
////    public void init() {
////        System.out.println(chromefile);
////        Constant.CHROMEFILE = chromefile;
////    }
//
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
//        Constant.CHROMEFILE=chromefile;
//        Constant.CHROMEDRIVEDIR=chromedrivedir;
//        System.out.println(chromefile);
//        System.setProperty("webdriver.chrome.driver", Constant.getchrome());
//
//        ChromePoolExecutor chromePoolExecutor1 = new ChromePoolExecutor(0);
//        HashMap<String, Chrome> pool1 = chromePoolExecutor1.getPool();
//        for (String s : pool1.keySet()) {
//            Chrome driver = pool1.get(s);
//            driver.get("https://am.iam.cnpc/login-pwd.html?appCode=cmsptr");
//            while (true){
//                try {
//                    driver.findElement(By.id("cnpc-input-userName"));
//                    break;
//                } catch (Exception e) {
//                }
//            }
//        }
//        ChromePoolExecutor chromePoolExecutor2 = new ChromePoolExecutor(0);
//        HashMap<String, Chrome> pool = chromePoolExecutor2.getPool();
//        for (String s : pool.keySet()) {
//            Chrome driver = pool.get(s);
//            driver.get("https://am.iam.cnpc/login-pwd.html?appCode=dzgw");
//            while (true){
//                try {
//                    driver.findElement(By.id("cnpc-input-userName"));
//                    break;
//                } catch (Exception e) {
//                }
//            }
//        }
//
//
//        Constant.chromePoolExecutor_contract=chromePoolExecutor1;
//        Constant.chromePoolExecutor_doc=chromePoolExecutor2;
//
//        //加载Phantomjs
////        String phantomjs = Constant.getPhantomjs();
////        System.out.println(phantomjs);
////        System.out.println(Constant.getchrome());
////        System.setProperty("phantomjs.binary.path", phantomjs);
//        //加载chrome
////        ChromeOptions options = new ChromeOptions();
////        options.addArguments("-headless");
////
//////        options.setBinary("C:\\Users\\ydmh\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
////        options.setBinary(chromefile);
//////        ChromeDriver chromeDriver = new ChromeDriver(options);
////        Constant.DRIVER= new ChromeDriver(options);
////
//////        RemoteWebDriver remoteWebDriver = new RemoteWebDriver(options);
//////        remoteWebDriver.get();
//////        remoteWebDriver.getWindowHandle();
//////        WebDriver driver = new ChromeDriver();
////        WebDriver.Options manage =  Constant.DRIVER.manage();
//////        WebDriver.Options manage = Constant.DRIVER.manage();
////        System.out.println("打开浏览器");
////        manage.timeouts().implicitlyWait(5, SECONDS);
////        System.out.println("设置超时");
//////        Thread t = Thread.currentThread();
//////        t.sleep(4000);
//////        chromeDriver.get("https://am.iam.cnpc/login-pwd.html?appCode=cmsptr");
//        System.out.println("==================初始化完毕===========================");
//
//    }
//}
